assert, switch to NDEBUG
authorJeroen van der Heijden <jeroen@transceptor.technology>
Wed, 10 Oct 2018 07:16:58 +0000 (09:16 +0200)
committerJeroen van der Heijden <jeroen@transceptor.technology>
Wed, 10 Oct 2018 07:16:58 +0000 (09:16 +0200)
39 files changed:
src/cexpr/cexpr.c
src/ctree/ctree.c
src/imap/imap.c
src/iso8601/iso8601.c
src/motd/motd.c [deleted file]
src/qpack/qpack.c
src/siri/args/args.c
src/siri/backup.c
src/siri/db/aggregate.c
src/siri/db/db.c
src/siri/db/ffile.c
src/siri/db/fifo.c
src/siri/db/forward.c
src/siri/db/group.c
src/siri/db/groups.c
src/siri/db/initsync.c
src/siri/db/insert.c
src/siri/db/listener.c
src/siri/db/median.c
src/siri/db/points.c
src/siri/db/pool.c
src/siri/db/pools.c
src/siri/db/props.c
src/siri/db/query.c
src/siri/db/reindex.c
src/siri/db/replicate.c
src/siri/db/series.c
src/siri/db/server.c
src/siri/db/servers.c
src/siri/db/shard.c
src/siri/db/user.c
src/siri/heartbeat.c
src/siri/help/help.c
src/siri/net/bserver.c
src/siri/net/clserver.c
src/siri/net/pkg.c
src/siri/net/stream.c
src/siri/optimize.c
src/siri/siri.c

index 89915f3513e54235df61fdb3b2f15aa35f0d2e51..61bb6fe507589f31b09b2f8562f3a0f3498316b5 100644 (file)
@@ -96,9 +96,7 @@ cexpr_t * cexpr_from_node(cleri_node_t * node)
     {
         /* successful */
         cexpr = CEXPR_close_curly(&list);
-#if DEBUG
         assert (list.len == 0 && condition == NULL);
-#endif
     }
     else if (condition != NULL)
     {
@@ -179,10 +177,7 @@ int cexpr_str_cmp(
         const char * b)
 {
     /* both a and b MUST be terminated strings */
-
-#if DEBUG
     assert (a != NULL && b != NULL);
-#endif
 
     switch (operator)
     {
@@ -218,9 +213,8 @@ int cexpr_bool_cmp(
         const int64_t a,
         const int64_t b)
 {
-#if DEBUG
     assert ((a == 0 || a == 1) && (b == 0 || b == 1));
-#endif
+
     switch (operator)
     {
     case CEXPR_EQ:
@@ -243,10 +237,8 @@ int cexpr_run(cexpr_t * cexpr, cexpr_cb_t cb, void * obj)
     switch (cexpr->operator)
     {
     case CEXPR_AND:
-#if DEBUG
         /* tp_a cannot be VIA_NULL, but tp_b can */
         assert (cexpr->tp_a != VIA_NULL);
-#endif
         return  ((cexpr->tp_a == VIA_CEXPR) ?
                     cexpr_run(cexpr->via_a.cexpr, cb, obj) :
                     cb(obj, cexpr->via_a.cond)) &&
@@ -254,10 +246,8 @@ int cexpr_run(cexpr_t * cexpr, cexpr_cb_t cb, void * obj)
                     cexpr_run(cexpr->via_b.cexpr, cb, obj) :
                     cb(obj, cexpr->via_b.cond)));
     case CEXPR_OR:
-#if DEBUG
         /* both tp_a and tp_b can NEVER be VIA_NULL */
         assert (cexpr->tp_a != VIA_NULL && cexpr->tp_b != VIA_NULL);
-#endif
         return  ((cexpr->tp_a == VIA_CEXPR) ?
                     cexpr_run(cexpr->via_a.cexpr, cb, obj) :
                     cb(obj, cexpr->via_a.cond)) ||
@@ -327,9 +317,7 @@ cexpr_operator_t cexpr_operator_fn(cleri_node_t * node)
     }
     else
     {
-#if DEBUG
         assert (node->len == 2);
-#endif
         switch (*node->str)
         {
         case '=': return CEXPR_EQ;
@@ -668,9 +656,7 @@ static void CEXPR_push_condition(cexpr_t * cexpr, cexpr_condition_t * cond)
     }
     else
     {
-#if DEBUG
-        assert(cexpr->tp_b == VIA_NULL);
-#endif
+        assert(cexpr->tp_b == VIA_NULL);#endif
         cexpr->tp_b = VIA_COND;
         cexpr->via_b.cond = cond;
     }
@@ -704,9 +690,7 @@ static cexpr_t * CEXPR_open_curly(cexpr_t * cexpr, cexpr_list_t * list)
     }
     else
     {
-#if DEBUG
         assert(cexpr->tp_b == VIA_NULL);
-#endif
         cexpr->tp_b = VIA_CEXPR;
         cexpr->via_b.cexpr = new_cexpr;
     }
@@ -716,9 +700,7 @@ static cexpr_t * CEXPR_open_curly(cexpr_t * cexpr, cexpr_list_t * list)
 
 static cexpr_t * CEXPR_close_curly(cexpr_list_t * list)
 {
-#if DEBUG
     assert (list->len > 0);
-#endif
     list->len--;
     return list->cexpr[list->len];
 }
index ba888464020a41098edc77ad718d6478be407a00..4d84a619ce73cbe602f27433652b1c0c03531c69 100644 (file)
@@ -630,10 +630,7 @@ static int CT_add(
  */
 static void CT_merge_node(ct_node_t * node)
 {
-#if DEBUG
     assert(node->size == 1 && node->data == NULL);
-#endif
-
     ct_node_t * child_node;
     char * tmp;
     uint_fast16_t i, end;
index 7271c9b67ebd766222b0ff933e84afc2f49a0a76..30739c251b5055c4dc49cf53603fce0f7ab91fad 100644 (file)
@@ -115,10 +115,8 @@ void imap_free(imap_t * imap, imap_free_cb cb)
  */
 int imap_set(imap_t * imap, uint64_t id, void * data)
 {
-#if DEBUG
     /* insert NULL is not allowed */
     assert (data != NULL);
-#endif
     int rc;
     imap_node_t * nd = imap->nodes + (id % IMAP_NODE_SZ);
     id /= IMAP_NODE_SZ;
@@ -160,10 +158,9 @@ int imap_set(imap_t * imap, uint64_t id, void * data)
  */
 int imap_add(imap_t * imap, uint64_t id, void * data)
 {
-#if DEBUG
     /* insert NULL is not allowed */
     assert (data != NULL);
-#endif
+
     imap_node_t * nd = imap->nodes + (id % IMAP_NODE_SZ);
     id /= IMAP_NODE_SZ;
 
@@ -460,10 +457,8 @@ void imap_union_ref(
             {
                 if (dest_nd->data != NULL)
                 {
-#if DEBUG
                     /* this must be the same object */
                     assert (imap_nd->data == dest_nd->data);
-#endif
                     /* we are sure there is a ref left */
                     slist_object_decref(imap_nd->data);
                 }
@@ -597,10 +592,9 @@ void imap_difference_ref(
             {
                 if (dest_nd->data != NULL)
                 {
-#if DEBUG
                     /* this must be the same object */
                     assert (imap_nd->data == dest_nd->data);
-#endif
+
                     /* we are sure to have one ref left */
                     slist_object_decref(dest_nd->data);
                     dest_nd->data = NULL;
@@ -667,10 +661,9 @@ void imap_symmetric_difference_ref(
             {
                 if (dest_nd->data != NULL)
                 {
-#if DEBUG
                     /* this must be the same object */
                     assert (imap_nd->data == dest_nd->data);
-#endif
+
                     /* we are sure to have one ref left */
                     slist_object_decref(dest_nd->data);
 
@@ -980,10 +973,8 @@ static void IMAP_union_ref(imap_node_t * dest, imap_node_t * node)
         {
             if (dest_nd->data != NULL)
             {
-#if DEBUG
                 /* this must be the same object */
                 assert (node_nd->data == dest_nd->data);
-#endif
                 /* we are sure there is a ref left */
                 slist_object_decref(node_nd->data);
             }
@@ -1087,10 +1078,8 @@ static void IMAP_difference_ref(
         {
             if (dest_nd->data != NULL)
             {
-#if DEBUG
                 /* this must be the same object */
                 assert (node_nd->data == dest_nd->data);
-#endif
                 /* we are sure to have one ref left */
                 slist_object_decref(dest_nd->data);
                 dest_nd->data = NULL;
@@ -1143,10 +1132,9 @@ static void IMAP_symmetric_difference_ref(
         {
             if (dest_nd->data != NULL)
             {
-#if DEBUG
                 /* this must be the same object */
                 assert (node_nd->data == dest_nd->data);
-#endif
+
                 /* we are sure to have one ref left */
                 slist_object_decref(dest_nd->data);
 
index 3b0217fa08c63e511d592a23e405e71ea9c01e08..dde56710d06c61e62969c78b10a53f287efd5805 100644 (file)
@@ -671,13 +671,11 @@ static int64_t get_ts(
     struct tm tm;
     time_t ts;
 
-#if DEBUG
     /* must be a valid timezone */
     assert (tz >= 0 && tz < TZ_LEN);
 
     /* timezone must be 0 (UTC) */
     assert (timezone == 0);
-#endif
 
     memset(&tm, 0, sizeof(struct tm));
 
diff --git a/src/motd/motd.c b/src/motd/motd.c
deleted file mode 100644 (file)
index 6b1eb18..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * motd.c - Message of the day
- *
- *  Note: all quotes are found somewhere on the Internet.
- *
- * author       : Jeroen van der Heijden
- * email        : jeroen@transceptor.technology
- * copyright    : 2016, Transceptor Technology
- *
- * changes
- *  - initial version, 13-03-2016
- *
- */
-#include <stdlib.h>
-#include <motd/motd.h>
-
-static const char * motd_messages[] = {
-        "If God had intended Man to program, \n"
-        "we'd be born with serial I/O ports.",
-
-        "\"On the Internet, no one knows you're using Windows NT\"\n"
-        "(Submitted by Ramiro Estrugo, restrugo@fateware.com)",
-
-        "Your mail is being routed through Germany ...\n"
-        "and they're censoring us.",
-
-        "There's got to be more to life than compile-and-go.",
-
-        "One person's error is another person's data.",
-
-        "Nobody said computers were going to be polite.",
-
-        "Little known fact about Middle Earth:\n"
-        "The Hobbits had a very sophisticated computer network!\n\n"
-        "It was a Tolkien Ring...",
-
-        "You can do anything, but not everything.\n\n"
-        "--David Allen",
-
-        "Perfection is achieved, not when there is nothing more to add,\n"
-        "but when there is nothing left to take away.\n\n"
-        "--Antoine de Saint-Exupéry",
-
-        "The richest man is not he who has the most,\n"
-        "but he who needs the least.\n\n"
-        "--Unknown Author",
-
-        "You miss 100 percent of the shots you never take.\n\n"
-        "--Wayne Gretzky",
-
-        "Courage is not the absence of fear,\n"
-        "but rather the judgment that something else is more "
-        "important than fear.\n\n"
-        "--Ambrose Redmoon",
-
-        "Everyone is a genius at least once a year.\n"
-        "The real geniuses simply have their bright ideas closer together.\n\n"
-        "--Georg Christoph Lichtenberg",
-
-        "Before I got married I had six theories about bringing up children;\n"
-        "now I have six children and no theories.\n\n"
-        "--John Wilmot",
-
-        "Those who believe in telekinetics, raise my hand.\n\n"
-        "--Kurt Vonnegut",
-
-        "We've heard that a million monkeys at a million keyboards could "
-        "produce the complete works of Shakespeare;\n"
-        "now, thanks to the Internet, we know that is not true.\n\n"
-        "--Robert Wilensky",
-
-        "The person who reads too much and uses his brain too little will "
-        "fall into lazy habits of thinking.\n\n"
-        "--Albert Einstein",
-
-        "Believe those who are seeking the truth. Doubt those who find it.\n\n"
-        "--André Gide",
-
-        "It is the mark of an educated mind to be able to entertain a thought "
-        "without accepting it.\n\n"
-        "--Aristotle",
-
-        "Pure mathematics is, in its way, the poetry of logical ideas.\n\n"
-        "--Albert Einstein",
-
-        "Do not worry about your difficulties in Mathematics. "
-        "I can assure you mine are still greater.\n\n"
-        "--Albert Einstein",
-
-        "While physics and mathematics may tell us how the universe began,\n"
-        "they are not much use in predicting human behavior because there "
-        "are far too many equations to solve.\n"
-        "I'm no better than anyone else at understanding what makes people "
-        "tick, particularly women.\n\n"
-        "--Stephen Hawking",
-
-        "'Obvious' is the most dangerous word in mathematics.\n\n"
-        "--E. T. Bell",
-
-        "Nobody ever figures out what life is all about, and it doesn't matter.\n"
-        "Explore the world.\n"
-        "Nearly everything is really interesting if you go into it deeply enough.\n\n"
-        "--Richard Feynman",
-
-        "Physics is like sex: sure, it may give some practical results, "
-        "but that's not why we do it.\n\n"
-        "--Richard Feynman",
-
-        "You have no responsibility to live up to what other people think "
-        "you ought to accomplish.\n"
-        "I have no responsibility to be like they expect me to be.\n"
-        "It's their mistake, not my failing.\n\n"
-        "--Richard Feynman",
-
-        "I learned very early the difference between knowing the name of "
-        "something and knowing something.\n\n"
-        "--Richard Feynman",
-
-        "Religion is a culture of faith; science is a culture of doubt.\n\n"
-        "--Richard Feynman",
-
-        "I think it's much more interesting to live not knowing than to have "
-        "answers which might be wrong.\n\n"
-        "--Richard Feynman"
-
-};
-
-#define MOTD_SIZE (sizeof (motd_messages) / sizeof (const char *))
-
-const char * motd_get_random_msg(void)
-{
-    return motd_messages[rand() % MOTD_SIZE];
-}
index 1e183a51f25c0fb2a03df5d1f6d694fb3a235a67..fb8e1a3ae9437faf6cc6058ba6b7d6977590795b 100644 (file)
@@ -142,9 +142,7 @@ void qp_unpacker_init(qp_unpacker_t * unpacker, unsigned char * pt, size_t len)
  */
 void qp_unpacker_ff_free(qp_unpacker_t * unpacker)
 {
-#if DEBUG
     assert(unpacker != NULL);
-#endif
     free(unpacker->source);
     free(unpacker);
 }
@@ -246,9 +244,7 @@ qp_packer_t * qp_packer_new(size_t alloc_size)
  */
 void qp_packer_free(qp_packer_t * packer)
 {
-#if DEBUG
     assert(packer != NULL);
-#endif
     free(packer->buffer);
     free(packer);
 }
@@ -587,10 +583,7 @@ int qp_add_null(qp_packer_t * packer) QP_PLAIN_OBJ(QP_NULL)
  */
 int qp_add_type(qp_packer_t * packer, qp_types_t tp)
 {
-#if DEBUG
     assert(tp >= QP_ARRAY0 && tp <= QP_MAP_CLOSE);
-#endif
-
     QP_RESIZE(1)
     packer->buffer[packer->len++] = tp;
     return 0;
@@ -601,10 +594,7 @@ int qp_add_type(qp_packer_t * packer, qp_types_t tp)
  */
 int qp_fadd_type(qp_fpacker_t * fpacker, qp_types_t tp)
 {
-#if DEBUG
     assert(tp >= QP_ARRAY0 && tp <= QP_MAP_CLOSE);
-#endif
-
     return (fputc(tp, fpacker) == (int) tp) ? 0 : EOF;
 }
 
index 040ca26593a5c7e2566f7d7acc7016669101fe49..e668257eaf75da55c55fb561c7fb29159bc72b58 100644 (file)
@@ -8,7 +8,7 @@
 #define DEFAULT_LOG_FILE_MAX_SIZE 50000000
 #define DEFAULT_LOG_FILE_NUM_BACKUPS 6
 
-#if DEBUG
+#ifndef NDEBUG
 #define DEFAULT_LOG_LEVEL "debug"
 #else
 #define DEFAULT_LOG_LEVEL "info"
index 7a843372845a6f7882fd2048caddc110c3c29e29..2ee9c723297a918042452c5cd1fbc4f56c22ab87 100644 (file)
@@ -63,10 +63,8 @@ void siri_backup_destroy(siri_t * siri)
  */
 int siri_backup_enable(siri_t * siri, siridb_t * siridb)
 {
-#if DEBUG
     assert (~siridb->server->flags & SERVER_FLAG_BACKUP_MODE);
     assert (~siridb->server->flags & SERVER_FLAG_REINDEXING);
-#endif
 
     llist_t * llist = (llist_t *) siri->backup->data;
 
@@ -105,9 +103,7 @@ int siri_backup_enable(siri_t * siri, siridb_t * siridb)
 
 int siri_backup_disable(siri_t * siri, siridb_t * siridb)
 {
-#if DEBUG
     assert (siridb->server->flags & SERVER_FLAG_BACKUP_MODE);
-#endif
 
     int rc = 0;
 
index bfc55d910ca947df7b7885c308cbd8182730c1a1..87c3a3010547d4e8966512d2c50d83d753c5d196 100644 (file)
@@ -493,10 +493,7 @@ siridb_points_t * siridb_aggregate_run(
         siridb_aggr_t * aggr,
         char * err_msg)
 {
-#if DEBUG
     assert (source->len);
-#endif
-
     if (aggr->limit)
     {
         return AGGREGATE_limit(source, aggr, err_msg);
@@ -1121,13 +1118,7 @@ static siridb_points_t * AGGREGATE_group_by(
             points->data = point;
         }
     }
-#if DEBUG
-    else
-    {
-        /* if not smaller it must be equal */
-        assert (points->len == max_sz);
-    }
-#endif
+    /* else { assert (points->len == max_sz); } */
 
     return points;
 }
@@ -1148,9 +1139,7 @@ static int aggr_derivative(
         siridb_aggr_t * aggr,
         char * err_msg)
 {
-#if DEBUG
     assert (points->len);
-#endif
 
     if (points->tp == TP_STRING)
     {
@@ -1194,9 +1183,7 @@ static int aggr_difference(
         siridb_aggr_t * aggr __attribute__((unused)),
         char * err_msg)
 {
-#if DEBUG
     assert (points->len);
-#endif
 
     switch (points->tp)
     {
@@ -1252,9 +1239,7 @@ static int aggr_max(
         siridb_aggr_t * aggr __attribute__((unused)),
         char * err_msg)
 {
-#if DEBUG
     assert (points->len);
-#endif
 
     if (points->tp == TP_STRING)
     {
@@ -1298,9 +1283,7 @@ static int aggr_mean(
         siridb_aggr_t * aggr __attribute__((unused)),
         char * err_msg)
 {
-#if DEBUG
     assert (points->len);
-#endif
 
     double sum = 0.0;
     size_t i;
@@ -1341,9 +1324,7 @@ static int aggr_median(
         siridb_aggr_t * aggr __attribute__((unused)),
         char * err_msg)
 {
-#if DEBUG
     assert (points->len);
-#endif
 
     if (points->tp == TP_STRING)
     {
@@ -1385,9 +1366,7 @@ static int aggr_median_high(
         siridb_aggr_t * aggr __attribute__((unused)),
         char * err_msg)
 {
-#if DEBUG
     assert (points->len);
-#endif
 
     if (points->tp == TP_STRING)
     {
@@ -1420,9 +1399,7 @@ static int aggr_median_low(
         siridb_aggr_t * aggr __attribute__((unused)),
         char * err_msg)
 {
-#if DEBUG
     assert (points->len);
-#endif
 
     if (points->tp == TP_STRING)
     {
@@ -1455,9 +1432,7 @@ static int aggr_min(
         siridb_aggr_t * aggr __attribute__((unused)),
         char * err_msg)
 {
-#if DEBUG
     assert (points->len);
-#endif
 
     if (points->tp == TP_STRING)
     {
@@ -1501,9 +1476,7 @@ static int aggr_pvariance(
         siridb_aggr_t * aggr __attribute__((unused)),
         char * err_msg)
 {
-#if DEBUG
     assert (points->len);
-#endif
 
     switch (points->tp)
     {
@@ -1530,9 +1503,7 @@ static int aggr_sum(
         siridb_aggr_t * aggr __attribute__((unused)),
         char * err_msg)
 {
-#if DEBUG
     assert (points->len);
-#endif
 
     switch (points->tp)
     {
@@ -1586,9 +1557,7 @@ static int aggr_variance(
         siridb_aggr_t * aggr __attribute__((unused)),
         char * err_msg)
 {
-#if DEBUG
     assert (points->len);
-#endif
 
     switch (points->tp)
     {
@@ -1616,9 +1585,7 @@ static int aggr_stddev(
         siridb_aggr_t * aggr __attribute__((unused)),
         char * err_msg)
 {
-#if DEBUG
     assert (points->len);
-#endif
 
     switch (points->tp)
     {
@@ -1646,9 +1613,8 @@ static int aggr_first(
         siridb_aggr_t * aggr __attribute__((unused)),
         char * err_msg __attribute__((unused)))
 {
-#if DEBUG
     assert (points->len);
-#endif
+
     siridb_point_t * source = points->data;
 
     switch (points->tp)
@@ -1682,9 +1648,8 @@ static int aggr_last(
         siridb_aggr_t * aggr __attribute__((unused)),
         char * err_msg __attribute__((unused)))
 {
-#if DEBUG
     assert (points->len);
-#endif
+
     siridb_point_t * source = points->data + (points->len - 1);
 
     switch (points->tp)
index 5923b14283d564277844e71ba9a991a8b9c71749..f7832b92f21b3a6c1290a17494d7e7241eea07a2 100644 (file)
@@ -572,10 +572,6 @@ int siridb_save(siridb_t * siridb)
  */
 void siridb__free(siridb_t * siridb)
 {
-#if DEBUG
-    log_debug("Free database: '%s'", siridb->dbname);
-#endif
-
     /* first we should close the buffer and all other open files */
     if (siridb->buffer != NULL)
     {
index c366521c0e02215132ccc65574b0aeaf34744cf8..853a3372230b55e7ec3256a6f368415315bbf7f2 100644 (file)
@@ -161,9 +161,7 @@ siridb_ffile_result_t siridb_ffile_append(
         siridb_ffile_t * ffile,
         sirinet_pkg_t * pkg)
 {
-#if DEBUG
     assert (ffile->fp != NULL);
-#endif
 
     uint32_t size = pkg->len + sizeof(sirinet_pkg_t);
 
@@ -211,10 +209,8 @@ int siridb_ffile_check_fn(const char * fn)
  */
 sirinet_pkg_t * siridb_ffile_pop(siridb_ffile_t * ffile)
 {
-#if DEBUG
     assert (ffile->next_size);
     assert (ffile->fp != NULL);
-#endif
     if (fseeko(
             ffile->fp,
             -(long int) (ffile->next_size + sizeof(uint32_t)),
@@ -260,9 +256,7 @@ sirinet_pkg_t * siridb_ffile_pop(siridb_ffile_t * ffile)
  */
 int siridb_ffile_pop_commit(siridb_ffile_t * ffile)
 {
-#if DEBUG
     assert (ffile->next_size && ffile->fp != NULL);
-#endif
 
     ffile->size -= ffile->next_size + sizeof(uint32_t);
 
index 11f0eed98d9d12b625aa6725dbe5b652704e399e..cd8b200db24ee5032792ff667cc26db09e554634 100644 (file)
@@ -91,9 +91,7 @@ siridb_fifo_t * siridb_fifo_new(siridb_t * siridb)
     /* we have at least one fifo in the list */
     fifo->out = (siridb_ffile_t *) llist_shift(fifo->fifos);
 
-#if DEBUG
     assert (fifo->out != NULL);
-#endif
 
     if (fifo->out->fp == NULL)
     {
@@ -217,9 +215,7 @@ int siridb_fifo_commit(siridb_fifo_t * fifo)
         }
     }
 
-#if DEBUG
     assert (fifo->out != NULL);
-#endif
 
     return siri_err;
 }
@@ -241,9 +237,7 @@ int siridb_fifo_commit_err(siridb_fifo_t * fifo)
  */
 int siridb_fifo_close(siridb_fifo_t * fifo)
 {
-#if DEBUG
     assert (fifo->in->fp != NULL);
-#endif
     int rc = 0;
 
     /* close the 'in' fifo */
@@ -266,10 +260,7 @@ int siridb_fifo_close(siridb_fifo_t * fifo)
  */
 int siridb_fifo_open(siridb_fifo_t * fifo)
 {
-#if DEBUG
     assert (fifo->in->fp == NULL);
-#endif
-
     /* open fifo 'in' */
     siridb_ffile_open(fifo->in, "r+");
 
index ca7192035156298ad686563fb1432785ba0d7fce..03f5ba272e87f1c167e54a6fc95c8f46586a1182 100644 (file)
@@ -93,10 +93,6 @@ void siridb_forward_free(siridb_forward_t * forward)
 
     /* free forward */
     free(forward);
-
-#if DEBUG
-    log_debug("Free forward!, hooray!");
-#endif
 }
 
 /*
index cb3f8cbd83a35e862235ed29373207ee11b0f1c1..085a074a3e5f295a122eb8d1e25ee6d0f495c554 100644 (file)
@@ -359,9 +359,6 @@ void siridb__group_free(siridb_group_t * group)
 {
     size_t i;
 
-#if DEBUG
-    log_debug("Free group: '%s'", group->name);
-#endif
     free(group->name);
     free(group->source);
 
index 2689746df386ad050c029525ebbf558818f746bd..f417abc5f8880964cf1613f2b0c71aedec8eb48b 100644 (file)
@@ -377,10 +377,6 @@ static int GROUPS_nseries(
 static void GROUPS_free(siridb_groups_t * groups)
 {
     size_t i;
-
-#if DEBUG
-    log_debug("Free groups");
-#endif
     free(groups->fn);
 
     if (groups->nseries != NULL)
@@ -604,10 +600,8 @@ static void GROUPS_init_groups(siridb_t * siridb)
     siridb_series_t * series;
     size_t i;
 
-#if DEBUG
     /* do not run this function when no groups need initialization */
     assert (siridb->groups->ngroups->len);
-#endif
 
     uv_mutex_lock(&siridb->series_mutex);
 
@@ -628,10 +622,8 @@ static void GROUPS_init_groups(siridb_t * siridb)
     {
         group = (siridb_group_t *) slist_pop(groups->ngroups);
 
-#if DEBUG
         /* we must be sure this group is empty */
         assert (group->series->len == 0);
-#endif
 
         if (~group->flags & GROUP_FLAG_DROPPED)
         {
index 6a1f94f82e78460daea9b87c011f0107165bf188..8392d6eabe15dc1dcecdb6ea6d7fd6faffec4f03 100644 (file)
@@ -240,11 +240,9 @@ void siridb_initsync_fopen(siridb_initsync_t * initsync, const char * opentype)
  */
 static void INITSYNC_next_series_id(siridb_t * siridb)
 {
-#if DEBUG
     assert (siridb->replicate != NULL);
     assert (siridb->replicate->status == REPLICATE_RUNNING ||
             siridb->replicate->status == REPLICATE_STOPPING);
-#endif
 
     siridb_initsync_t * initsync = siridb->replicate->initsync;
 
@@ -297,9 +295,7 @@ static void INITSYNC_next_series_id(siridb_t * siridb)
  */
 static void INITSYNC_pause(siridb_replicate_t * replicate)
 {
-#if DEBUG
     assert (replicate->status == REPLICATE_STOPPING);
-#endif
     if (fclose(replicate->initsync->fp))
     {
         log_critical("Error occurred while closing file: '%s'",
@@ -317,9 +313,7 @@ static void INITSYNC_pause(siridb_replicate_t * replicate)
 static void INITSYNC_send(uv_timer_t * timer)
 {
     siridb_t * siridb = (siridb_t *) timer->data;
-#if DEBUG
     assert (siridb->replicate->initsync->pkg != NULL);
-#endif
 
     if (siridb->replicate->status == REPLICATE_STOPPING)
     {
@@ -355,13 +349,12 @@ static void INITSYNC_send(uv_timer_t * timer)
 static void INITSYNC_work(uv_timer_t * timer)
 {
     siridb_t * siridb = (siridb_t *) timer->data;
-#if DEBUG
+
     assert (siridb->replicate->status == REPLICATE_RUNNING ||
             siridb->replicate->status == REPLICATE_STOPPING);
     assert (siridb->replicate->initsync != NULL);
     assert (siridb->replicate->initsync->fp != NULL);
     assert (siridb->replicate->initsync->pkg == NULL);
-#endif
 
     if (siridb->insert_tasks)
     {
@@ -519,9 +512,7 @@ static inline int INITSYNC_fn(siridb_t * siridb, siridb_initsync_t * initsync)
  */
 static int INITSYNC_unlink(siridb_initsync_t * initsync)
 {
-#if DEBUG
     assert (initsync->fp != NULL);
-#endif
     fclose(initsync->fp);
     initsync->fp = NULL;
 
index cd1f6b143897707c6a96a2513267e8e7113baee3..2615839a6ddd5260f10bae37062e9d1bd65889c5 100644 (file)
@@ -151,10 +151,6 @@ void siridb_insert_free(siridb_insert_t * insert)
 
     /* free insert */
     free(insert);
-
-#if DEBUG
-    log_debug("Free insert!, hooray!");
-#endif
 }
 
 /*
@@ -968,9 +964,7 @@ static void INSERT_local_promise_cb(
         sirinet_pkg_t * pkg,
         int status)
 {
-#if DEBUG
     assert (pkg == NULL);
-#endif
     pkg = sirinet_pkg_new(
             0,
             0,
@@ -988,9 +982,7 @@ static void INSERT_local_promise_backend_cb(
         sirinet_pkg_t * pkg,
         int status)
 {
-#if DEBUG
     assert (pkg == NULL);
-#endif
     sirinet_stream_t * client = promise->data;
 
     pkg = sirinet_pkg_new(
@@ -1231,9 +1223,7 @@ static uint16_t INSERT_get_pool(siridb_t * siridb, qp_obj_t * qp_series_name)
              * the previous correct pool. (we can do this now
              * because we known we don't have the series)
              */
-#if DEBUG
             assert (siridb->pools->prev_lookup != NULL);
-#endif
             pool = siridb_lookup_sn_raw(
                     siridb->pools->prev_lookup,
                     (const char *) qp_series_name->via.raw,
index 4e35ad63a0fc349dbd9bd7258bdf26afccbd1e12..7186653956222416cd36a066e0b4c785f4b8db19 100644 (file)
@@ -580,9 +580,7 @@ static void enter_alter_stmt(uv_async_t * handle)
     siridb_user_t * db_user = query->client->origin;
     SIRIPARSER_MASTER_CHECK_ACCESS(db_user, SIRIDB_ACCESS_ALTER)
 
-#if DEBUG
     assert (query->packer == NULL);
-#endif
 
     query->packer = sirinet_packer_new(1024);
 
@@ -643,9 +641,7 @@ static void enter_count_stmt(uv_async_t * handle)
     siridb_user_t * db_user = query->client->origin;
     SIRIPARSER_MASTER_CHECK_ACCESS(db_user, SIRIDB_ACCESS_COUNT)
 
-#if DEBUG
     assert (query->packer == NULL);
-#endif
 
     query->packer = sirinet_packer_new(256);
 
@@ -709,9 +705,7 @@ static void enter_drop_stmt(uv_async_t * handle)
     siridb_query_t * query = (siridb_query_t *) handle->data;
     siridb_user_t * db_user = query->client->origin;
 
-#if DEBUG
     assert (query->packer == NULL);
-#endif
 
     SIRIPARSER_MASTER_CHECK_ACCESS(db_user, SIRIDB_ACCESS_DROP)
 
@@ -899,9 +893,7 @@ static void enter_list_stmt(uv_async_t * handle)
     siridb_user_t * db_user = query->client->origin;
     SIRIPARSER_MASTER_CHECK_ACCESS(db_user, SIRIDB_ACCESS_LIST)
 
-#if DEBUG
     assert (query->packer == NULL);
-#endif
 
     query->packer = sirinet_packer_new(QP_SUGGESTED_SIZE);
 
@@ -1013,9 +1005,7 @@ static void enter_select_stmt(uv_async_t * handle)
     SIRIPARSER_MASTER_CHECK_ACCESS(db_user, SIRIDB_ACCESS_SELECT)
     MASTER_CHECK_ACCESSIBLE(siridb)
 
-#if DEBUG
     assert (query->packer == NULL && query->data == NULL);
-#endif
 
     query->data = q_select = query_select_new();
 
@@ -1659,9 +1649,7 @@ static void exit_calc_stmt(uv_async_t * handle)
     siridb_query_t * query = (siridb_query_t *) handle->data;
     cleri_node_t * calc_node = query->nodes->node;
 
-#if DEBUG
     assert (query->packer == NULL);
-#endif
 
     query->packer = sirinet_packer_new(64);
 
@@ -2233,9 +2221,7 @@ static void exit_create_group(uv_async_t * handle)
     }
     else
     {
-#if DEBUG
         assert (query->packer == NULL);
-#endif
         query->packer = sirinet_packer_new(1024);
         if (query->packer == NULL)
         {
@@ -2270,11 +2256,9 @@ static void exit_create_user(uv_async_t * handle)
     cleri_node_t * user_node =
             query->nodes->node->children->next->node;
 
-#if DEBUG
     /* both name and packer should be NULL at this point */
     assert(user->name == NULL);
     assert(query->packer == NULL);
-#endif
 
     MASTER_CHECK_ACCESSIBLE(siridb)
 
@@ -2298,9 +2282,7 @@ static void exit_create_user(uv_async_t * handle)
         /* success, increment the user reference counter */
         siridb_user_incref(user);
 
-#if DEBUG
         assert (query->packer == NULL);
-#endif
         query->packer = sirinet_packer_new(1024);
 
         if (query->packer == NULL)
@@ -2704,9 +2686,7 @@ static void exit_grant_user(uv_async_t * handle)
         return;
     }
 
-#if DEBUG
     assert (query->packer == NULL);
-#endif
 
     query->packer = sirinet_packer_new(1024);
 
@@ -2742,9 +2722,7 @@ static void exit_help_xxx(uv_async_t * handle)
 
     if (query->data != NULL)
     {
-#if DEBUG
         assert (query->packer == NULL);
-#endif
         const char * help = siri_help_get(
                 query->nodes->node->cl_obj->gid,
                 (const char *) query->data,
@@ -3258,9 +3236,7 @@ static void exit_revoke_user(uv_async_t * handle)
         return;
     }
 
-#if DEBUG
     assert (query->packer == NULL);
-#endif
 
     query->packer = sirinet_packer_new(1024);
 
@@ -3572,10 +3548,8 @@ static void exit_set_backup_mode(uv_async_t * handle)
     siridb_query_t * query = (siridb_query_t *) handle->data;
     siridb_t * siridb = query->client->siridb;
 
-#if DEBUG
     assert (query->data != NULL);
     assert (IS_MASTER);
-#endif
 
     siridb_server_t * server = ((query_alter_t *) query->data)->via.server;
 
@@ -3798,9 +3772,7 @@ static void exit_set_log_level(uv_async_t * handle)
     query_alter_t * q_alter = (query_alter_t *) query->data;
     siridb_t * siridb = query->client->siridb;
 
-#if DEBUG
     assert (query->data != NULL);
-#endif
 
     cleri_node_t * node =
             query->nodes->node->children->next->next->node->children->node;
@@ -4127,9 +4099,7 @@ static void exit_show_stmt(uv_async_t * handle)
             query->nodes->node->children->next->node->children;
     siridb_props_cb prop_cb;
 
-#if DEBUG
     assert (query->packer == NULL);
-#endif
 
     query->packer = sirinet_packer_new(4096);
 
@@ -4167,9 +4137,7 @@ static void exit_show_stmt(uv_async_t * handle)
             /* get the callback */
             prop_cb = siridb_props[children->node->children->node->
                                    cl_obj->gid - KW_OFFSET];
-#if DEBUG
             assert (prop_cb != NULL);  /* all props are implemented */
-#endif
             prop_cb(siridb, query->packer, 1);
 
             if (children->next == NULL)
@@ -4618,9 +4586,7 @@ static void async_no_points_aggregate(uv_async_t * handle)
          */
         siridb_series_decref(series);
 
-#if DEBUG
         assert (q_select->alist->len >= 1);
-#endif
 
         siridb_aggr_t * aggr = q_select->alist->data[0];
 
@@ -5934,11 +5900,8 @@ static void on_select_unpack_merged_points(
     siridb_points_t * points;
 
     while ( qp_is_raw(qp_next(unpacker, qp_name)) &&
-#if DEBUG
             qp_is_raw_term(qp_name) &&
-#endif
             qp_is_array(qp_next(unpacker, NULL)))
-
     {
         slist_t ** plist = (slist_t **) ct_getaddr(
                 q_select->result,
index 1c2e2f79758d81650bd6e2f2c2ef078c9f00013c..bac54eb04f254fc96668b257f3d47a1e7c16fada 100644 (file)
@@ -54,9 +54,7 @@ int siridb_median_find_n(
         siridb_points_t * points,
         uint64_t n)
 {
-#if DEBUG
     assert (points->len >= 2);
-#endif
     int rc = 0;
     uint64_t i, npivot, size_l, size_r;
 
@@ -183,9 +181,7 @@ int siridb_median_real(
         siridb_points_t * points,
         double percentage)
 {
-#if DEBUG
     assert (points->len >= 2);
-#endif
     int rc = 0;
     uint64_t i, npivot, size_l, size_r, n;
     bool found_a, found_b;
index c78b9c8b2f82b8835c8cce5c3943f80cd58e7b21..7edcf5bbff54c5005b7abb024389b08bcb038a71 100644 (file)
@@ -291,9 +291,7 @@ int siridb_points_raw_pack(siridb_points_t * points, qp_packer_t * packer)
  */
 siridb_points_t * siridb_points_merge(slist_t * plist, char * err_msg)
 {
-#if DEBUG
     assert (plist->len >= 2);
-#endif
     siridb_points_t * points;
     siridb_points_t * tpts = NULL;
     size_t n = 0;
@@ -340,10 +338,8 @@ siridb_points_t * siridb_points_merge(slist_t * plist, char * err_msg)
         i++;
     }
 
-#if DEBUG
     /* we have at least one series left */
     assert (plist->len >= 1);
-#endif
 
     if (plist->len == 1)
     {
@@ -1410,10 +1406,8 @@ static void POINTS_highest_and_merge(slist_t * plist, siridb_points_t * points)
             usleep(3000);
         }
     }
-#if DEBUG
     /* size should be exactly zero */
     assert (n == 0);
-#endif
 }
 
 
@@ -1458,10 +1452,8 @@ static void POINTS_sort_while_merge(slist_t * plist, siridb_points_t * points)
             usleep(3000);
         }
     }
-#if DEBUG
     /* size should be exactly zero */
     assert (n == 0);
-#endif
 }
 
 /*
@@ -1499,10 +1491,8 @@ static void POINTS_merge_and_sort(slist_t * plist, siridb_points_t * points)
         }
     }
 
-#if DEBUG
     /* size should be exactly zero */
     assert (n == 0);
-#endif
 
     usleep(5000);
 
index af34cc15b6419245478b9240bbf787ef62e80f83..d1613782217e97466ac0f0586e1c05b4b181c11f 100644 (file)
@@ -124,10 +124,8 @@ void siridb_pool_add_server(siridb_pool_t * pool, siridb_server_t * server)
     }
     else
     {
-#if DEBUG
         /* we can only have 1 or 2 servers per pool */
         assert (pool->len == 2);
-#endif
         /* add the server to the pool, ordered by UUID */
         if (siridb_server_cmp(pool->server[0], server) < 0)
         {
@@ -136,9 +134,7 @@ void siridb_pool_add_server(siridb_pool_t * pool, siridb_server_t * server)
         }
         else
         {
-#if DEBUG
             assert (siridb_server_cmp(pool->server[0], server) > 0);
-#endif
             pool->server[1] = pool->server[0];
             pool->server[0] = server;
 
index 722b9f2c67629a5b1d588a3aafe294d0c003b43f..81c6c0cc12efab66d0334195839645b4db734d35 100644 (file)
@@ -28,11 +28,9 @@ static void POOLS_arrange(siridb_server_t * server, siridb_t * siridb);
  */
 void siridb_pools_init(siridb_t * siridb)
 {
-#if DEBUG
     assert (siridb->pools == NULL);
     assert (siridb->servers != NULL && siridb->servers->len > 0);
     assert (siridb->server != NULL);
-#endif
 
     siridb->pools = malloc(sizeof(siridb_pools_t));
     if (siridb->pools == NULL)
@@ -123,9 +121,9 @@ siridb_pool_t * siridb_pools_append(
             pool->len = 0;
             siridb_pool_add_server(pool, server);
             pools->len++;
-#if DEBUG
+
             assert (pools->prev_lookup == NULL);
-#endif
+
             pools->prev_lookup = pools->lookup;
             pools->lookup = lookup;
         }
index dcfbe980e37d1d9e18d06895a0b3e7dcb0a423a4..9b01312f763fba274218f856b76979b98cab04ab 100644 (file)
@@ -523,10 +523,8 @@ static void prop_time_precision(
 {
     SIRIDB_PROP_MAP("time_precision", 14)
 
-#if DEBUG
     assert (siridb->time->precision >= SIRIDB_TIME_SECONDS &&
             siridb->time->precision <= SIRIDB_TIME_NANOSECONDS);
-#endif
 
     qp_add_string(packer, siridb_time_short_map[siridb->time->precision]);
 }
index 1f7f9b100d05dbafe9838ab798fa4edbbe25d29f..21fcdeb6b66b65e7f6e5eb0e344544c0e5941c7c 100644 (file)
 #include <sys/time.h>
 #include <siri/err.h>
 
-#if DEBUG
-#include <motd/motd.h>
-#endif
-
 #define QUERY_TOO_LONG -1
 #define QUERY_MAX_LENGTH 8192
 #define QUERY_EXTRA_ALLOC_SIZE 200
@@ -179,10 +175,6 @@ void siridb_query_free(uv_handle_t * handle)
 
     /* free handle */
     free(handle);
-
-    #if DEBUG
-    log_debug("Free query!, hooray!");
-    #endif
 }
 
 void siridb_send_query_result(uv_async_t * handle)
@@ -192,13 +184,9 @@ void siridb_send_query_result(uv_async_t * handle)
      * clean everything without sending things in case of a client failure
      */
     siridb_query_t * query = (siridb_query_t *) handle->data;
-#if DEBUG
-    if (query->packer == NULL)
-    {
-        sprintf(query->err_msg, "CRITICAL: We have nothing to send!");
-        return siridb_query_send_error(handle, CPROTO_ERR_QUERY);
-    }
-#endif
+
+    assert (query->packer != NULL);
+
     sirinet_pkg_t * pkg = sirinet_packer2pkg(
             query->packer,
             query->pid,
@@ -319,13 +307,10 @@ void siridb_query_forward(
             break;
 
         case SIRIDB_QUERY_FWD_SOME_POOLS:
-#if DEBUG
-
             assert (((query_select_t *) ((siridb_query_t *)
                     handle->data)->data)->tp == QUERIES_SELECT);
             assert (((query_select_t *) ((siridb_query_t *)
                     handle->data)->data)->pmap != NULL);
-#endif
             pkg->tp = BPROTO_QUERY_SERVER;
             {
                 slist_t * borrow_list = imap_slist(((query_select_t *) (
@@ -405,9 +390,7 @@ void siridb_query_timeit_from_unpacker(
         siridb_query_t * query,
         qp_unpacker_t * unpacker)
 {
-#if DEBUG
     assert (query->timeit != NULL);
-#endif
 
     qp_types_t tp = qp_next(unpacker, NULL);
 
@@ -530,8 +513,6 @@ static void QUERY_send_no_query(uv_async_t * handle)
     query->packer = sirinet_packer_new(512);
     qp_add_type(query->packer, QP_MAP1);
 
-#ifndef DEBUG
-    /* production version returns timestamp now */
     siridb_t * siridb = query->client->siridb;
 
     qp_add_raw(query->packer, (const unsigned char *) "calc", 4);
@@ -547,15 +528,6 @@ static void QUERY_send_no_query(uv_async_t * handle)
         qp_add_int64(query->packer, (int64_t) (ts * factor));
     }
 
-#else
-    /* development release returns motd */
-    const char * msg;
-    msg = motd_get_random_msg();
-    qp_add_raw(query->packer, (const unsigned char *) "motd", 4);
-    qp_add_string(query->packer, msg);
-
-
-#endif
     siridb_send_query_result(handle);
 }
 
index 7f74e3a70ee6a43d58c7f171c9cb70e978605b78..7087d59a7f7752faf4aa1c8fab2d3cf4bb2582a3 100644 (file)
@@ -221,9 +221,8 @@ const char * siridb_reindex_progress(siridb_t * siridb)
  */
 void siridb_reindex_close(siridb_reindex_t * reindex)
 {
-#if DEBUG
     assert (reindex != NULL && reindex->timer != NULL);
-#endif
+
     /* we can use uv_timer_stop() even if the timer is not scheduled */
     uv_timer_stop(reindex->timer);
     uv_close((uv_handle_t *) reindex->timer, (uv_close_cb) free);
@@ -239,10 +238,7 @@ void siridb_reindex_close(siridb_reindex_t * reindex)
  */
 void siridb_reindex_free(siridb_reindex_t ** reindex)
 {
-#if DEBUG
     assert ((*reindex)->timer == NULL);
-    log_debug("Free re-index");
-#endif
     if ((*reindex)->fp != NULL && fclose((*reindex)->fp))
     {
         ERR_FILE
@@ -282,10 +278,8 @@ void siridb_reindex_fopen(siridb_reindex_t * reindex, const char * opentype)
  */
 void siridb_reindex_status_update(siridb_t * siridb)
 {
-#if DEBUG
     assert (~siridb->server->flags & SERVER_FLAG_REINDEXING);
     assert (siridb->flags & SIRIDB_FLAG_REINDEXING);
-#endif
     if (siridb_servers_available(siridb))
     {
         siridb->flags &= ~SIRIDB_FLAG_REINDEXING;
@@ -313,9 +307,7 @@ void siridb_reindex_start(uv_timer_t * timer)
     }
     else
     {
-#if DEBUG
         assert (siri.optimize->pause);
-#endif
         if (!SIRI_OPTIMZE_IS_PAUSED)
         {
             log_debug("Wait for the optimize task to pause");
@@ -338,9 +330,7 @@ void siridb_reindex_start(uv_timer_t * timer)
 static void REINDEX_send(uv_timer_t * timer)
 {
     siridb_t * siridb = (siridb_t *) timer->data;
-#if DEBUG
     assert (siridb->reindex->pkg != NULL);
-#endif
     /* actually 'available' is sufficient since the destination server has
      * never status 're-indexing' unless one day we support down-scaling.
      */
@@ -454,11 +444,9 @@ static void REINDEX_work(uv_timer_t * timer)
     siridb_t * siridb = (siridb_t *) timer->data;
     siridb_reindex_t * reindex = siridb->reindex;
 
-#if DEBUG
     assert (SIRI_OPTIMZE_IS_PAUSED);
     assert (reindex != NULL);
     assert (siridb->reindex->pkg == NULL);
-#endif
 
     reindex->series = imap_get(siridb->series_map, *reindex->next_series_id);
 
@@ -477,11 +465,9 @@ static void REINDEX_work(uv_timer_t * timer)
          * lock is not needed since we are sure the optimize task is
          * not running
          */
-#if DEBUG
         assert (siridb_lookup_sn(
                     siridb->pools->prev_lookup,
                     reindex->series->name) == siridb->server->pool);
-#endif
         siridb_points_t * points = siridb_series_get_points(
                 reindex->series,
                 NULL,
@@ -661,9 +647,7 @@ static inline int REINDEX_fn(siridb_t * siridb, siridb_reindex_t * reindex)
  */
 static int REINDEX_unlink(siridb_reindex_t * reindex)
 {
-#if DEBUG
     assert (reindex->fp != NULL);
-#endif
     fclose(reindex->fp);
     reindex->fp = NULL;
 
index 9f0cda2612292cbf9209ddb70b740b8f9ecf5159..f2daa976ffc1b020c88c45d3fb1115bfbd87276f 100644 (file)
@@ -44,9 +44,7 @@ static void REPLICATE_on_repl_finished_response(
  */
 int siridb_replicate_init(siridb_t * siridb, siridb_initsync_t * initsync)
 {
-#if DEBUG
     assert (siri.loop != NULL);
-#endif
 
     siridb->replicate =
             (siridb_replicate_t *) malloc(sizeof(siridb_replicate_t));
@@ -83,11 +81,9 @@ int siridb_replicate_init(siridb_t * siridb, siridb_initsync_t * initsync)
  */
 void siridb_replicate_close(siridb_replicate_t * replicate)
 {
-#if DEBUG
     assert (replicate != NULL &&
             replicate->timer != NULL &&
             replicate->status != REPLICATE_CLOSED);
-#endif
     /* we can use uv_timer_stop() even if the timer is not scheduled */
     uv_timer_stop(replicate->timer);
     uv_close((uv_handle_t *) replicate->timer, (uv_close_cb) free);
@@ -103,10 +99,7 @@ void siridb_replicate_close(siridb_replicate_t * replicate)
  */
 void siridb_replicate_free(siridb_replicate_t ** replicate)
 {
-#if DEBUG
-    log_debug("Free replicate");
     assert ((*replicate)->status == REPLICATE_CLOSED);
-#endif
     if ((*replicate)->initsync != NULL)
     {
         siridb_initsync_free(&(*replicate)->initsync);
@@ -136,9 +129,7 @@ int siridb_replicate_pkg(siridb_t * siridb, sirinet_pkg_t * pkg)
  */
 void siridb_replicate_start(siridb_replicate_t * replicate)
 {
-#if DEBUG
     assert (siridb_replicate_is_idle(replicate));
-#endif
     replicate->status = REPLICATE_RUNNING;
     if (replicate->initsync == NULL)
     {
@@ -161,9 +152,7 @@ void siridb_replicate_start(siridb_replicate_t * replicate)
  */
 void siridb_replicate_pause(siridb_replicate_t * replicate)
 {
-#if DEBUG
     assert (replicate->status != REPLICATE_CLOSED);
-#endif
     replicate->status = (replicate->status == REPLICATE_IDLE) ?
         REPLICATE_PAUSED : REPLICATE_STOPPING;
 }
@@ -175,11 +164,9 @@ void siridb_replicate_pause(siridb_replicate_t * replicate)
  */
 void siridb_replicate_continue(siridb_replicate_t * replicate)
 {
-#if DEBUG
     /* make sure the fifo buffer is open */
     assert (siridb_fifo_is_open(((siridb_t *) replicate->timer->data)->fifo));
     assert (replicate->status != REPLICATE_CLOSED);
-#endif
 
     replicate->status = (replicate->status == REPLICATE_STOPPING) ?
             REPLICATE_RUNNING : REPLICATE_IDLE;
@@ -212,7 +199,6 @@ static void REPLICATE_work(uv_timer_t * handle)
     siridb_t * siridb = (siridb_t *) handle->data;
     sirinet_pkg_t * pkg;
 
-#if DEBUG
     assert (siridb->fifo != NULL);
     assert (siridb->replicate != NULL);
     assert (siridb->replica != NULL);
@@ -221,7 +207,6 @@ static void REPLICATE_work(uv_timer_t * handle)
     assert (siridb->replicate->status != REPLICATE_CLOSED);
     assert (siridb->replicate->initsync == NULL);
     assert (siridb_fifo_is_open(siridb->fifo));
-#endif
 
     if (    siridb->replicate->status == REPLICATE_RUNNING &&
             siridb_fifo_has_data(siridb->fifo) &&
@@ -333,11 +318,9 @@ static void REPLICATE_on_repl_response(
 {
     siridb_t * siridb = (siridb_t *) promise->data;
 
-#if DEBUG
     /* open promises must be closed before siridb->replicate is destroyed */
     assert (siridb->replicate != NULL);
     assert (siridb->fifo != NULL);
-#endif
 
     switch ((sirinet_promise_status_t) status)
     {
index 563539a180b4618d5930d403c60aa27b563c4e3d..12e9598ba95beb4b6c8d691f587f567857c2038b 100644 (file)
@@ -127,10 +127,8 @@ int siridb_series_add_point(
         uint64_t * ts,
         qp_via_t * val)
 {
-#if DEBUG
     assert (!siri_err);
     assert (series->buffer != NULL);
-#endif
     int rc = 0;
 
     series->length++;
@@ -340,13 +338,6 @@ void siridb__series_free(siridb_series_t *__restrict series)
     siridb_shard_t * shard;
     uint_fast32_t i;
 
-#if DEBUG
-    if (siri.status == SIRI_STATUS_RUNNING || 0)
-    {
-        log_debug("Free series: '%s'", series->name);
-    }
-#endif
-
     /* mark shards with dropped series flag */
     for (i = 0; i < series->idx_len; i++)
     {
@@ -379,10 +370,8 @@ int siridb_series_load(siridb_t * siridb)
 {
     imap_t * dropped;
 
-#if DEBUG
     /* we must have a server because we need to know the pool id */
     assert (siridb->server != NULL);
-#endif
     log_info("Loading series");
 
     dropped = imap_new();
@@ -509,9 +498,7 @@ void siridb_series_drop_prepare(siridb_t * siridb, siridb_series_t * series)
  */
 int siridb_series_drop_commit(siridb_t * siridb, siridb_series_t * series)
 {
-#if DEBUG
     assert (series->flags & SIRIDB_SERIES_IS_DROPPED);
-#endif
 
     int rc = 0;
 
@@ -813,10 +800,8 @@ siridb_points_t * siridb_series_get_first(
 
     (*required_shard)++;
 
-#if DEBUG
     /* if not in the buffer, then if must be in a shard */
     assert (series->idx_len);
-#endif
 
     idx_t * first = series->idx;
 
@@ -835,11 +820,9 @@ siridb_points_t * siridb_series_get_first(
             &start,
             series->flags & SIRIDB_SERIES_HAS_OVERLAP);
 
-#if DEBUG
     /* we must have at least one point, more points are possible when
      * having multiple points at the same time-stamp. */
     assert (points->len);
-#endif
 
     while (points->len > 1)
     {
@@ -879,11 +862,8 @@ siridb_points_t * siridb_series_get_last(
 
     (*required_shard)++;
 
-
-#if DEBUG
     /* if not in the buffer, then if must be in a shard */
     assert (series->idx_len);
-#endif
 
     /* if not in the buffer, then if must be in a shard */
 
@@ -912,11 +892,9 @@ siridb_points_t * siridb_series_get_last(
             NULL,
             series->flags & SIRIDB_SERIES_HAS_OVERLAP);
 
-#if DEBUG
     /* we must have at least one point, more points are possible when
      * having multiple points at the same time-stamp. */
     assert (points->len);
-#endif
 
     while (points->len > 1)
     {
@@ -1079,13 +1057,11 @@ int siridb_series_optimize_shard(
             size += idx->len;
             end++;
 
-#if DEBUG
             /*
              * we have at least 2 references to the shard so we never
              * reach 0 here.  (this ref + optimize ref)
              */
             assert(shard->replacing->ref >= 2);
-#endif
             siridb_shard_decref(shard->replacing);
         }
         else if (idx->shard == shard && end)
@@ -1170,9 +1146,7 @@ int siridb_series_optimize_shard(
             }
             while (idx->shard == shard);
 
-#if DEBUG
             assert (idx->shard == shard->replacing);
-#endif
 
             idx->shard = shard;
             idx->start_ts = points->data[pstart].ts;
@@ -1235,13 +1209,11 @@ int siridb_series_optimize_shard(
             series->idx = idx;
         }
     }
-#if DEBUG
     else
     {
         /* start must be equal to end if not smaller */
         assert (i == end);
     }
-#endif
 
     if (series->flags & SIRIDB_SERIES_HAS_OVERLAP)
     {
@@ -1326,9 +1298,8 @@ static void SERIES_update_overlap(siridb_series_t *__restrict series)
 {
     uint_fast32_t i;
 
-#if DEBUG
     assert (series->flags & SIRIDB_SERIES_HAS_OVERLAP);
-#endif
+
     for (i = 1; i < series->idx_len; i++)
     {
         if (series->idx[i - 1].end_ts > series->idx[i].start_ts)
@@ -1397,11 +1368,9 @@ static siridb_series_t * SERIES_new(
                 series->flags |= SIRIDB_SERIES_IS_SERVER_ONE;
             }
 
-#if DEBUG
             /* make sure these two are exactly the same */
             assert (siridb_series_server_id(series) ==
                     siridb_series_server_id_by_name(series->name));
-#endif
 
             if (siridb->time->precision == SIRIDB_TIME_SECONDS)
             {
index 778c150bdda4855205a52c89322733dce7d3dc79..cfe7c0114de31cd97b1425db9d084080331eeae4 100644 (file)
@@ -135,11 +135,9 @@ int siridb_server_send_pkg(
         void * data,
         int flags)
 {
-#if DEBUG
     assert (server->client != NULL);
     assert (server->promises != NULL);
     assert (cb != NULL);
-#endif
     int rc;
     uint8_t n = 0;
     sirinet_promise_t * promise =
@@ -309,16 +307,12 @@ siridb_server_t * siridb_server_register(
 void siridb_server_send_flags(siridb_server_t * server)
 {
 
-#if DEBUG
     assert (server->client != NULL);
     assert (siridb_server_is_online(server));
-#endif
 
     sirinet_stream_t * client = server->client;
 
-#if DEBUG
     assert (client->siridb != NULL);
-#endif
 
     int16_t n = client->siridb->server->flags;
     QP_PACK_INT16(buffer, n)
@@ -402,10 +396,8 @@ int siridb_server_update_address(
  */
 void siridb_server_connect(siridb_t * siridb, siridb_server_t * server)
 {
-#if DEBUG
     /* server->socket must be NULL at this point */
     assert (server->client == NULL);
-#endif
 
     server->client = sirinet_stream_new(STREAM_TCP_SERVER, &SERVER_on_data);
 
@@ -880,17 +872,13 @@ siridb_server_t * siridb_server_from_node(
 int siridb_server_drop(siridb_t * siridb, siridb_server_t * server)
 {
     int rc = 0;
-#if DEBUG
     assert (siridb->server != server);
-#endif
     siridb_pool_t * pool = siridb->pools->pool + server->pool;
 
     switch (server->id)
     {
     case 0:
-#if DEBUG
         assert (pool->len == 2);
-#endif
         pool->server[0] = pool->server[1];
         pool->server[0]->id = 0;
         /* FALLTHRU */
@@ -933,12 +921,11 @@ int siridb_server_drop(siridb_t * siridb, siridb_server_t * server)
         siridb_server_decref(server);
         rc = siridb_servers_save(siridb);
     }
-#if DEBUG
     else
     {
+        /* can never be reached */
         assert (0);
     }
-#endif
     return rc;
 }
 
@@ -950,9 +937,6 @@ int siridb_server_drop(siridb_t * siridb, siridb_server_t * server)
  */
 void siridb__server_free(siridb_server_t * server)
 {
-#if DEBUG
-    log_debug("Free server: '%s'", server->name);
-#endif
     /* we MUST first free the promises because each promise has a reference to
      * this server and the promise callback might depend on this.
      */
@@ -1230,9 +1214,7 @@ static int SERVER_update_name(siridb_server_t * server)
     char * tmp;
     int fmt_as_ipv6 = 0;  /* false */
 
-#if DEBUG
     assert (server->port > 0);
-#endif
 
     /* append 'string' length for server->port */
     for (; i; i /= 10, len++);
@@ -1246,9 +1228,7 @@ static int SERVER_update_name(siridb_server_t * server)
     /* append 'address' length */
     len += strlen(server->address);
 
-#if DEBUG
     assert (len > 0);
-#endif
 
     /* allocate enough space */
     tmp = (char *) realloc(server->name, len);
index 9c6aea6010e32b8d62106b05f9ac9ae7855039c5..a083efbc1b9b4af65c49ede76fdc040602f13e90 100644 (file)
@@ -236,11 +236,9 @@ int siridb_servers_register(siridb_t * siridb, siridb_server_t * server)
         if (siridb->server->pool == server->pool)
         {
             /* this is a replica for 'this' pool */
-#if DEBUG
             assert (siridb->replicate == NULL);
             assert (siridb->fifo == NULL);
             assert (siridb->replica == NULL);
-#endif
             siridb->replica = server;
             siridb->fifo = siridb_fifo_new(siridb);
 
index cef762326e57271d6f995b662559fd24d855e059..8b5d4905fc7b415b270a8e6165646f20b2c2493a 100644 (file)
@@ -1540,10 +1540,6 @@ void siridb__shard_free(siridb_shard_t * shard)
     /* this will close the file, even when other references exist */
     siri_fp_decref(shard->fp);
 
-#if DEBUG
-    log_debug("Free shard id: %" PRIu64, shard->id);
-#endif
-
     free(shard->fn);
     free(shard);
 }
index 72111c8aa2e62d31a7508ee3eb02a79e2de1c8f5..5a0f1ed849a3bcf3572f5b1ad0b5e29012741aca 100644 (file)
@@ -238,9 +238,6 @@ int siridb_user_cexpr_cb(siridb_user_t * user, cexpr_condition_t * cond)
  */
 void siridb__user_free(siridb_user_t * user)
 {
-#if DEBUG
-    log_debug("Free user: '%s'", user->name);
-#endif
     free(user->name);
     free(user->password);
     free(user);
index e398f499fe2dedab6fc45bf829d4d9192970dbc2..9e8f23f6ac104641328cac3118386401d0bda0d0 100644 (file)
@@ -59,9 +59,7 @@ static void HEARTBEAT_cb(uv_timer_t * handle __attribute__((unused)))
     llist_node_t * siridb_node;
     llist_node_t * server_node;
 
-#if DEBUG
     log_debug("Start heart-beat task");
-#endif
 
     siridb_node = siri.siridb_list->first;
 
index 068fb35a159cccc78aeb8924b6719f47bb42eb2a..4c6a1ad71628e069778cc425a56e69207c02ff16 100644 (file)
@@ -122,10 +122,6 @@ void siri_help_free(void)
 {
     uint_fast16_t i;
 
-#if DEBUG
-    log_debug("Free help");
-#endif
-
     for (i = 0; i < HELP_COUNT; i ++)
     {
         free(siri_help_content[i]);
index 46a80022ce50bbcc15dcbcd1dec3342272b6e941..85a527dd01a19e8911d90b6258c7703b8009ba69 100644 (file)
@@ -75,9 +75,7 @@ static uv_tcp_t backend_server;
 
 int sirinet_bserver_init(siri_t * siri)
 {
-#if DEBUG
     assert (loop == NULL);
-#endif
 
     int rc;
     int ip_v6 = 0;  /* false */
@@ -518,9 +516,7 @@ static void on_insert(
     siridb_t * siridb = client->siridb;
     if ((flags & INSERT_FLAG_POOL) && siridb->replica != NULL)
     {
-#if DEBUG
         assert (siridb->fifo != NULL);
-#endif
         sirinet_pkg_t * repl_pkg;
 
         if (siridb->replicate->initsync == NULL)
index 65ba365f30b233f0a0456b7fc5bf342b49176370..bd0bcbc94debc8b0c17cd47ebe12c634abcf3206 100644 (file)
@@ -106,9 +106,7 @@ static void CLSERVER_on_register_server_response(
 
 int sirinet_clserver_init(siri_t * siri)
 {
-#if DEBUG
     assert (loop == NULL && siri->loop != NULL);
-#endif
 
     int rc;
     int ip_v6 = 0;  /* false */
index dc6b2f94e124339330b9387a0eb218571d455767..5a78260b73b536eb546e7394075197d1eccfe8b2 100644 (file)
@@ -67,9 +67,7 @@ sirinet_pkg_t * sirinet_pkg_new(
  */
 qp_packer_t * sirinet_packer_new(size_t alloc_size)
 {
-#if DEBUG
     assert (alloc_size >= sizeof(sirinet_pkg_t));
-#endif
 
     qp_packer_t * packer = qp_packer_new(alloc_size);
     if (packer == NULL)
@@ -119,9 +117,7 @@ sirinet_pkg_t * sirinet_pkg_err(
         uint8_t tp,
         const char * msg)
 {
-#if DEBUG
     assert (msg != NULL);
-#endif
 
     sirinet_pkg_t * pkg;
     qp_packer_t * packer = sirinet_packer_new(len + 20 + sizeof(sirinet_pkg_t));
index ae1c644a88077f9cc71f21aafb14174ef40715be..32c94695102b0ec8afeee69df992855a0cdbd12b 100644 (file)
@@ -250,10 +250,6 @@ void sirinet__stream_free(uv_stream_t * uvclient)
 {
     sirinet_stream_t * client = uvclient->data;
 
-#if DEBUG
-    log_debug("Free socket client type: %d", client->tp);
-#endif
-
     switch (client->tp)
     {
     case STREAM_PIPE_CLIENT:
index 4a22b64414eb1bda05291320c1dd9fa2aca8372c..c55adf191b8c4a854fe639e34e49211789fb7248 100644 (file)
@@ -98,9 +98,7 @@ void siri_optimize_pause(void)
  */
 void siri_optimize_continue(void)
 {
-#if DEBUG
     assert (optimize.pause);
-#endif
     if (!--optimize.pause && optimize.status == SIRI_OPTIMIZE_PAUSED_MAIN)
     {
         log_debug("Optimize task was paused by the main thread, continue...");
@@ -118,9 +116,7 @@ int siri_optimize_wait(void)
     /* its possible that another database is paused, but we wait anyway */
     if (optimize.pause)
     {
-#if DEBUG
         assert (optimize.status == SIRI_OPTIMIZE_RUNNING);
-#endif
         optimize.status = SIRI_OPTIMIZE_PAUSED;
 
         /* close open index file in case this is required */
@@ -185,9 +181,8 @@ int siri_optimize_wait(void)
  */
 int siri_optimize_create_idx(const char * fn)
 {
-#if DEBUG
     assert (optimize.idx_fn == NULL && strlen(fn) > 3);
-#endif
+
     /* copy file name */
     optimize.idx_fn = strdup(fn);
     if (optimize.idx_fn == NULL)
@@ -308,9 +303,7 @@ static void OPTIMIZE_work(uv_work_t * work  __attribute__((unused)))
         size_t j;
         siridb = (siridb_t *) slsiridb->data[i];
 
-#if DEBUG
         log_debug("Start optimizing database '%s'", siridb->dbname);
-#endif
 
         uv_mutex_lock(&siridb->shards_mutex);
 
@@ -383,9 +376,7 @@ static void OPTIMIZE_work(uv_work_t * work  __attribute__((unused)))
         {
             break;
         }
-#if DEBUG
         log_debug("Finished optimizing database '%s'", siridb->dbname);
-#endif
     }
     OPTIMIZE_cleanup(slsiridb);
 }
index 8db933fbcbce85563a4cab9971f2b6f27b8378c2..683e08f3d33ee27fc84348242370116116221158 100644 (file)
@@ -103,7 +103,7 @@ void siri_setup_logger(void)
     char lname[255];
     size_t len = strlen(siri.args->log_level);
 
-#ifndef DEBUG
+#ifdef NDEBUG
     /* force colors while debugging... */
     if (siri.args->log_colorized)
 #endif
@@ -515,7 +515,7 @@ static void SIRI_walk_close_handlers(
         /* we do not expect any timer object since they should all be closed
          * (or at least closing) at this point.
          */
-#if DEBUG
+#ifndef NDEBUG
         LOGC(   "Found a non closing Timer, all timers should "
                 "be stopped at this point.");
 #endif
@@ -524,7 +524,7 @@ static void SIRI_walk_close_handlers(
         break;
 
     case UV_ASYNC:
-#if DEBUG
+#ifndef NDEBUG
         LOGC(   "An async task is only expected to be found in case "
                 "not all tasks were closed within the timeout limit, "
                 "or when a critical signal error is raised.");
@@ -534,7 +534,7 @@ static void SIRI_walk_close_handlers(
 
     default:
 
-#if DEBUG
+#ifndef NDEBUG
         LOGC("Oh oh, we might need to implement type %d", handle->type);
         assert(0);
 #endif